﻿/*
EBS 数据库初始化脚本 FOR SQLSERVER
Date: 2019-08-18 00:53:00
*/

CREATE DATABASE EBS_DB

GO

USE EBS_DB

GO

-- ----------------------------
-- Table structure for ebs_account
-- ----------------------------
CREATE TABLE [ebs_account] (
[oid] varchar(40) NOT NULL ,
[create_date] datetime2(7) NULL ,
[password] varchar(20) NOT NULL ,
[status] int NULL ,
[type] int NULL ,
[username] varchar(20) NOT NULL ,
[current_app_id] varchar(40) NULL
)


GO

-- ----------------------------
-- Records of ebs_account
-- ----------------------------
BEGIN TRANSACTION
GO
INSERT INTO [ebs_account] ([oid], [create_date], [password], [status], [type], [username], [current_app_id]) VALUES (N'00000000-0000-0000-0000-000000000000', N'2019-07-31 18:31:39.0000000', N'123456', N'1', N'0', N'platform', null), (N'00000000-0000-0000-0000-000000000001', N'2019-07-31 18:32:07.0000000', N'123456', N'1', N'1', N'dev', null)
GO
GO
COMMIT TRANSACTION
GO

-- ----------------------------
-- Table structure for ebs_app
-- ----------------------------
CREATE TABLE [ebs_app] (
[oid] varchar(40) NOT NULL ,
[dev] varchar(40) NOT NULL ,
[name] varchar(255) NULL ,
[status] int NULL ,
[create_date] datetime2(7) NOT NULL
)


GO

-- ----------------------------
-- Records of ebs_app
-- ----------------------------
BEGIN TRANSACTION
GO
COMMIT TRANSACTION
GO

-- ----------------------------
-- Table structure for ebs_app_account_role
-- ----------------------------
CREATE TABLE [ebs_app_account_role] (
[oid] varchar(40) NOT NULL ,
[account_id] varchar(40) NOT NULL ,
[app_id] varchar(40) NOT NULL ,
[role_id] varchar(40) NOT NULL
)


GO

-- ----------------------------
-- Records of ebs_app_account_role
-- ----------------------------
BEGIN TRANSACTION
GO
COMMIT TRANSACTION
GO

-- ----------------------------
-- Table structure for ebs_app_power
-- ----------------------------
CREATE TABLE [ebs_app_power] (
[oid] varchar(40) NOT NULL ,
[app_id] varchar(40) NOT NULL ,
[code] varchar(50) NOT NULL ,
[icon] varchar(100) NULL ,
[name] varchar(50) NOT NULL ,
[order_no] int NULL ,
[parent_id] varchar(40) NULL ,
[type] int NULL
)


GO

-- ----------------------------
-- Records of ebs_app_power
-- ----------------------------
BEGIN TRANSACTION
GO
COMMIT TRANSACTION
GO

-- ----------------------------
-- Table structure for ebs_app_role
-- ----------------------------
CREATE TABLE [ebs_app_role] (
[oid] varchar(40) NOT NULL ,
[app_id] varchar(255) NULL ,
[code] varchar(50) NOT NULL ,
[name] varchar(255) NULL ,
[status] int NULL ,
[create_date] datetime2(7) NOT NULL
)


GO

-- ----------------------------
-- Records of ebs_app_role
-- ----------------------------
BEGIN TRANSACTION
GO
COMMIT TRANSACTION
GO

-- ----------------------------
-- Table structure for ebs_app_role_power
-- ----------------------------
CREATE TABLE [ebs_app_role_power] (
[oid] varchar(40) NOT NULL ,
[power_id] varchar(40) NOT NULL ,
[role_id] varchar(40) NOT NULL
)


GO

-- ----------------------------
-- Records of ebs_app_role_power
-- ----------------------------
BEGIN TRANSACTION
GO
COMMIT TRANSACTION
GO

-- ----------------------------
-- Table structure for ebs_app_role_rule
-- ----------------------------
CREATE TABLE [ebs_app_role_rule] (
[oid] varchar(40) NOT NULL ,
[role_id] varchar(40) NOT NULL ,
[rule_id] varchar(40) NOT NULL
)


GO

-- ----------------------------
-- Records of ebs_app_role_rule
-- ----------------------------
BEGIN TRANSACTION
GO
COMMIT TRANSACTION
GO

-- ----------------------------
-- Table structure for ebs_app_rule
-- ----------------------------
CREATE TABLE [ebs_app_rule] (
[oid] varchar(40) NOT NULL ,
[app_id] varchar(40) NOT NULL ,
[methods] varchar(100) NULL ,
[url_pattern] varchar(100) NOT NULL ,
[create_date] datetime2(7) NOT NULL
)


GO

-- ----------------------------
-- Records of ebs_app_rule
-- ----------------------------
BEGIN TRANSACTION
GO
COMMIT TRANSACTION
GO

-- ----------------------------
-- Table structure for ebs_app_tenant
-- ----------------------------
CREATE TABLE [ebs_app_tenant] (
[oid] varchar(40) NOT NULL ,
[app_id] varchar(40) NOT NULL ,
[end_date] datetime2(7) NULL ,
[ent_id] varchar(40) NULL ,
[start_date] datetime2(7) NULL ,
[status] int NULL ,
[create_date] datetime2(7) NOT NULL
)


GO

-- ----------------------------
-- Records of ebs_app_tenant
-- ----------------------------
BEGIN TRANSACTION
GO
COMMIT TRANSACTION
GO

-- ----------------------------
-- Table structure for ebs_ent
-- ----------------------------
CREATE TABLE [ebs_ent] (
[oid] varchar(40) NOT NULL ,
[name] varchar(255) NULL ,
[order_no] int NULL ,
[remark] varchar(255) NULL ,
[status] int NULL
)


GO

-- ----------------------------
-- Records of ebs_ent
-- ----------------------------
BEGIN TRANSACTION
GO
COMMIT TRANSACTION
GO

-- ----------------------------
-- Table structure for ebs_ent_dept
-- ----------------------------
CREATE TABLE [ebs_ent_dept] (
[oid] varchar(40) NOT NULL ,
[ent_id] varchar(255) NULL ,
[name] varchar(255) NULL ,
[order_no] int NULL
)


GO

-- ----------------------------
-- Records of ebs_ent_dept
-- ----------------------------
BEGIN TRANSACTION
GO
COMMIT TRANSACTION
GO

-- ----------------------------
-- Table structure for ebs_personnel
-- ----------------------------
CREATE TABLE [ebs_personnel] (
[oid] varchar(40) NOT NULL ,
[account_id] varchar(255) NULL ,
[birth_date] date NULL ,
[dept_id] varchar(255) NULL ,
[email] varchar(100) NULL ,
[ent_id] varchar(255) NULL ,
[order_no] int NULL ,
[personnel_name] varchar(255) NOT NULL ,
[sex] int NULL ,
[status] int NULL ,
[tel] varchar(50) NULL ,
[create_date] datetime2(7) NOT NULL
)


GO

-- ----------------------------
-- Records of ebs_personnel
-- ----------------------------
BEGIN TRANSACTION
GO
COMMIT TRANSACTION
GO

-- ----------------------------
-- Table structure for ebs_tenant_admin
-- ----------------------------
CREATE TABLE [ebs_tenant_admin] (
[oid] varchar(40) NOT NULL ,
[account_id] varchar(40) NOT NULL ,
[tenant_id] varchar(40) NOT NULL
)


GO

-- ----------------------------
-- Records of ebs_tenant_admin
-- ----------------------------
BEGIN TRANSACTION
GO
COMMIT TRANSACTION
GO

-- ----------------------------
-- Indexes structure for table ebs_account
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ebs_account
-- ----------------------------
ALTER TABLE [ebs_account] ADD PRIMARY KEY ([oid])
GO

-- ----------------------------
-- Indexes structure for table ebs_app
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ebs_app
-- ----------------------------
ALTER TABLE [ebs_app] ADD PRIMARY KEY ([oid])
GO

-- ----------------------------
-- Indexes structure for table ebs_app_account_role
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ebs_app_account_role
-- ----------------------------
ALTER TABLE [ebs_app_account_role] ADD PRIMARY KEY ([oid])
GO

-- ----------------------------
-- Indexes structure for table ebs_app_power
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ebs_app_power
-- ----------------------------
ALTER TABLE [ebs_app_power] ADD PRIMARY KEY ([oid])
GO

-- ----------------------------
-- Indexes structure for table ebs_app_role
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ebs_app_role
-- ----------------------------
ALTER TABLE [ebs_app_role] ADD PRIMARY KEY ([oid])
GO

-- ----------------------------
-- Indexes structure for table ebs_app_role_power
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ebs_app_role_power
-- ----------------------------
ALTER TABLE [ebs_app_role_power] ADD PRIMARY KEY ([oid])
GO

-- ----------------------------
-- Indexes structure for table ebs_app_role_rule
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ebs_app_role_rule
-- ----------------------------
ALTER TABLE [ebs_app_role_rule] ADD PRIMARY KEY ([oid])
GO

-- ----------------------------
-- Indexes structure for table ebs_app_rule
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ebs_app_rule
-- ----------------------------
ALTER TABLE [ebs_app_rule] ADD PRIMARY KEY ([oid])
GO

-- ----------------------------
-- Indexes structure for table ebs_app_tenant
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ebs_app_tenant
-- ----------------------------
ALTER TABLE [ebs_app_tenant] ADD PRIMARY KEY ([oid])
GO

-- ----------------------------
-- Indexes structure for table ebs_ent
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ebs_ent
-- ----------------------------
ALTER TABLE [ebs_ent] ADD PRIMARY KEY ([oid])
GO

-- ----------------------------
-- Indexes structure for table ebs_ent_dept
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ebs_ent_dept
-- ----------------------------
ALTER TABLE [ebs_ent_dept] ADD PRIMARY KEY ([oid])
GO

-- ----------------------------
-- Indexes structure for table ebs_personnel
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ebs_personnel
-- ----------------------------
ALTER TABLE [ebs_personnel] ADD PRIMARY KEY ([oid])
GO

-- ----------------------------
-- Indexes structure for table ebs_tenant_admin
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ebs_tenant_admin
-- ----------------------------
ALTER TABLE [ebs_tenant_admin] ADD PRIMARY KEY ([oid])
GO
